<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

//2010-01-22 去掉了手工对类文件的载入，改用autoload函数来动态载入所需的类文件
//
//the core file
if(!defined('TinyFW')) exit('Access denied!');

class tfCore {
    /*
    public static function autoload($classname) {
        if(file_exists(SYS_PATH . DS . "core" . DS . $classname . ".php")) {
            include_once(SYS_PATH . DS . "core" . DS . $classname . ".php");
        }

        if(file_exists(SYS_PATH . DS . "libs" . DS . $classname . ".class.php")) {
            include_once(SYS_PATH . DS . "libs" . DS . $classname . ".class.php");
        }
    }
    */

    public function __construct() {

        //$this->_include_core_files();
        //$this->_load_config();
        //$this->_load_core_libs();
        include_once(SYS_PATH . "core" . DS . "tfLoader.php");

        tfLoader::autoloadRegister();
        //spl_autoload_register(array('tfCore','autoload'));
        //set up the time zone;
        if(tfConfig::getConfig("timezone") <> '') {
            date_default_timezone_set(tfConfig::getConfig("timezone"));
        }

        if(tfConfig::getConfig('app_environ') == 'dev') {
            ini_set('display_errors', true);
            ini_set('error_reporting', E_ALL && ~E_DEPRECATED);
            //error_reporting(E_ALL && ~E_DEPRECATED);
        }

        //set up error handler
        tfError::setErrorExceptionHandler();
        //set_error_handler(array('tfError','tfErrorHandler'));
        //set_exception_handler(array('tfError','tfExceptionHandler'));

    }

    /**
     *
     * @param <type> $file_name
     * @return <type>
     */
    /*
    public function _include_files($file_name) {
        if(file_exists(SYS_PATH . "libs/".$file_name)) {
            include_once(SYS_PATH . "libs/".$file_name);
            return TRUE;
        } elseif (file_exists(APP_PATH . "libs/".$file_name)) {
            include_once(APP_PATH . "libs/".$file_name);
            return TRUE;
        } else {
            trigger_error("Cannot find file " . $file_name . "in libs directory!", E_USER_ERROR);
            return FALSE;
        }
    }
    */

    //include core files
    /*private function _include_core_files() {
        include_once(SYS_PATH . "core".DS ."Config.php");
        include_once(SYS_PATH . "core".DS."Loader.php");
        //include_once(SYS_PATH . "core".DS."Registry.php");
        //include_once(SYS_PATH . "core".DS."Cookie.php");
        //include_once(SYS_PATH . "core".DS."Error.php");
        //include_once(SYS_PATH . "core".DS."Model.php");
        //include_once(SYS_PATH . "core".DS."Session.php");
        include_once(SYS_PATH . "core".DS."Router.php");
        include_once(SYS_PATH . "core".DS."Uri.php");
        include_once(SYS_PATH . "core".DS."Action.php");
        include_once(SYS_PATH . "core".DS."Request.php");
        include_once(SYS_PATH . "core".DS."Template.php");
    
    }
    */

    /*private function _load_core_libs() {
        $this->_include_core_files();
        //Loader::load_core_library();
    }
    */

    public function dispatch() {
        //return Router::singleton()->dispatch();
        return tfRouter::dispatch();
    }

}


?>
